#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "Counter.h"

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    // 注册C++类到QML
    qmlRegisterType<Counter>("CounterModule", 1, 0, "Counter");

    QQmlApplicationEngine engine;

    // 创建Counter实例并设置为上下文属性
    Counter counter;
    engine.rootContext()->setContextProperty("counter", &counter);

    // 加载QML文件
    engine.load(QUrl(QStringLiteral("qrc:/forQuick/qml/CounterExample/main.qml")));

    return app.exec();
}